﻿namespace IS.Projecto.DataAccessLayer.impl
{
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;
    using Modelo;
    using NHibernate.Criterion;

    public class HorarioDao : GenericDao<Horario>, IHorarioDao
    {
        #region IHorarioDao Members

        public IList<Horario> GetHorarios(IList<UnidadeCurricular> ucs, DateTime start, DateTime end)
        {
            var ucIds = (ICollection)(from p in ucs
                                      select p.Id).ToList();

            return Session.CreateCriteria(typeof (Horario))
                .Add(Restrictions.In("UcId", ucIds))
                .Add(Restrictions.Ge("DataHora", start))
                .Add(Restrictions.Lt("DataHora", end.AddDays(1)))
                .List<Horario>();
        }

        #endregion
    }
}